home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DRenderer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-13  |  43.9 KB  |  1,348 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DRenderer.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Renderer types and routines                                   **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1997 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DRenderer_h
  15. #define QD3DRenderer_h
  16.  
  17. #include "QD3D.h"
  18. #include "QD3DView.h"
  19. #include "QD3DSet.h"
  20.  
  21. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  22.     #pragma once
  23. #endif  /*  PRAGMA_ONCE  */
  24.  
  25. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  26.  
  27. #if defined(__xlc__) || defined(__XLC121__)
  28.     #pragma options enum=small
  29. #endif
  30.  
  31. #include <Events.h>
  32.  
  33. #if defined(__xlc__) || defined(__XLC121__)
  34.     #pragma options enum=reset
  35.     #pragma options enum=int
  36.     #pragma options align=power
  37. #elif defined(__MWERKS__)
  38.     #pragma enumsalwaysint on
  39.     #pragma options align=native
  40. #elif defined(__MRC__) || defined(__SC__)
  41.     #if __option(pack_enums)
  42.         #define PRAGMA_ENUM_RESET_QD3DRENDER 1
  43.     #endif
  44.     #pragma options(!pack_enums)
  45.     #pragma options align=power
  46. #endif
  47.  
  48. #endif  /* OS_MACINTOSH */
  49.  
  50. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  51.     #include "windows.h"
  52. #endif /* WINDOW_SYSTEM_WIN32 */
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif    /* __cplusplus */
  57.  
  58. /******************************************************************************
  59.  **                                                                             **
  60.  **                            User Interface Things                             **
  61.  **                                                                             **
  62.  *****************************************************************************/
  63.  
  64. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  65.  
  66. /*
  67.  *  A callback to an application's event handling code. This is needed to    
  68.  *  support movable modal dialogs. The dialog's event filter calls this      
  69.  *  callback with events it does not handle.                                 
  70.  *  If an application handles the event it should return kQ3True.            
  71.  *  If the application does not handle the event it must return kQ3False and 
  72.  *  the dialog's event filter will pass the event to the system unhandled.   
  73.  */
  74. typedef TQ3Boolean (QD3D_CALLBACK *TQ3MacOSDialogEventHandler)( 
  75.     const EventRecord     *event);
  76.  
  77. typedef struct TQ3DialogAnchor {
  78.     TQ3MacOSDialogEventHandler clientEventHandler;
  79. } TQ3DialogAnchor;
  80.  
  81. #elif defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  82.  
  83. typedef struct TQ3DialogAnchor {
  84.     HWND    ownerWindow;    
  85. } TQ3DialogAnchor;
  86.  
  87. #else  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  88.  
  89. typedef struct TQ3DialogAnchor {
  90.     void    *notUsed;  /* place holder */
  91. } TQ3DialogAnchor;
  92.  
  93. #endif  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  94.  
  95.  
  96. /******************************************************************************
  97.  **                                                                             **
  98.  **                                Renderer Functions                             **
  99.  **                                                                             **
  100.  *****************************************************************************/
  101.  
  102. QD3D_EXPORT TQ3RendererObject QD3D_CALL Q3Renderer_NewFromType(
  103.     TQ3ObjectType            rendererObjectType);
  104.  
  105. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Renderer_GetType(
  106.     TQ3RendererObject        renderer);
  107.  
  108.  
  109.  
  110. /*
  111.  *    Q3Renderer_IsInteractive
  112.  *        Determine if this renderer is intended to be used interactively.
  113.  */
  114. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Renderer_IsInteractive(
  115.     TQ3RendererObject        renderer);
  116.  
  117.  
  118. /*
  119.  *    Q3Renderer_HasModalConfigure
  120.  *        Determine if this renderer has a modal settings dialog.
  121.  *
  122.  *    Q3Renderer_ModalConfigure
  123.  *        Have the renderer pop up a modal dialog box to configure its settings.
  124.  *    dialogAnchor - is platform specific data passed by the client to support
  125.  *      movable modal dialogs. 
  126.  *    MacOS: this is a callback to the calling application's event handler.
  127.  *      The renderer calls this function with events not handled by the 
  128.  *      settings dialog. This is necessary in order to support movable modal 
  129.  *      dialogs. An application's event handler must return kQ3True if it 
  130.  *      handles the event passed to the callback or kQ3False if not. 
  131.  *      An application which doesn't want to support a movable modal configure
  132.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  133.  *    Win32: this is the HWND of the owning window (typically an application's
  134.  *      main window).
  135.  *  canceled - returns a boolean inditacating that the user canceled the 
  136.  *    dialog.
  137.  *      
  138.  */
  139. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Renderer_HasModalConfigure(
  140.     TQ3RendererObject        renderer);
  141.  
  142. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_ModalConfigure(
  143.     TQ3RendererObject        renderer, 
  144.     TQ3DialogAnchor         dialogAnchor, 
  145.     TQ3Boolean                *canceled);
  146.     
  147. /*
  148.  *    Q3RendererClass_GetNickNameString
  149.  *        Allows an application to get a renderers name string, the 
  150.  *        renderer is responsible for storing this in a localizable format
  151.  *        for example as a resource.  This string can then be used to provide
  152.  *        a selection mechanism for an application (for example in a menu).
  153.  *
  154.  *        If this call returns nil in the supplied string, then the App may 
  155.  *         choose to use the class name for the renderer.  You should always 
  156.  *        try to get the name string before using the class name, since the
  157.  *        class name is not localizable.
  158.  */
  159. QD3D_EXPORT TQ3Status QD3D_CALL Q3RendererClass_GetNickNameString(
  160.     TQ3ObjectType                rendererClassType, 
  161.     TQ3ObjectClassNameString     rendererClassString);
  162.     
  163.  
  164. /*
  165.  *    Q3Renderer_GetConfigurationData
  166.  *        Allows an application to collect private renderer configuration data
  167.  *      which it will then save. For example in a preference file or in a 
  168.  *        style template. An application should tag this data with the 
  169.  *        Renderer's object  name.
  170.  *    
  171.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  172.  *        bytes of a data buffer large enough to store private data. 
  173.  *
  174.  *      bufferSize is the actual size of the memory block pointed to by 
  175.  *        dataBuffer
  176.  *
  177.  *        actualDataSize - on return the actual number of bytes written to the 
  178.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  179.  * 
  180.  */
  181. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_GetConfigurationData(
  182.     TQ3RendererObject        renderer, 
  183.     unsigned char            *dataBuffer, 
  184.     unsigned long            bufferSize,
  185.     unsigned long            *actualDataSize);
  186.  
  187. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_SetConfigurationData(
  188.     TQ3RendererObject        renderer, 
  189.     unsigned char            *dataBuffer, 
  190.     unsigned long            bufferSize);
  191.  
  192.  
  193.  
  194. /******************************************************************************
  195.  **                                                                             **
  196.  **                        Interactive Renderer Specific Functions                 **
  197.  **                                                                             **
  198.  *****************************************************************************/
  199.  
  200. /* 
  201.  *  CSG IDs attribute 
  202.  */
  203. #define kQ3AttributeTypeConstructiveSolidGeometryID \
  204.     Q3_OBJECT_TYPE('c','s','g','i')
  205.  
  206.  
  207. /* 
  208.  *  Object IDs, to be applied as attributes on geometries 
  209.  */
  210. #define kQ3SolidGeometryObjNone    -1
  211. #define kQ3SolidGeometryObjA     0
  212. #define kQ3SolidGeometryObjB     1
  213. #define kQ3SolidGeometryObjC     2
  214. #define kQ3SolidGeometryObjD     3
  215. #define kQ3SolidGeometryObjE     4
  216.  
  217. /* 
  218.  *  Possible CSG equations 
  219.  */
  220. typedef enum TQ3CSGEquation {
  221.     kQ3CSGEquationAandB            = (int)0x88888888,
  222.     kQ3CSGEquationAandnotB         = 0x22222222,
  223.     kQ3CSGEquationAanBonCad        = 0x2F222F22,
  224.     kQ3CSGEquationnotAandB        = 0x44444444,
  225.     kQ3CSGEquationnAaBorCanB    = 0x74747474
  226. } TQ3CSGEquation;
  227.  
  228. typedef enum TQ3HiddenSurfaceRemovalMode {
  229.     kQ3HiddenSurfaceRemovalMode_None,
  230.     kQ3HiddenSurfaceRemovalMode_Shallow,
  231.     kQ3HiddenSurfaceRemovalMode_Deep
  232. } TQ3HiddenSurfaceRemovalMode;
  233.  
  234. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetCSGEquation(
  235.     TQ3RendererObject        renderer,
  236.     TQ3CSGEquation            equation);
  237.  
  238. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetCSGEquation(
  239.     TQ3RendererObject        renderer,
  240.     TQ3CSGEquation            *equation);
  241.  
  242. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetPreferences(
  243.     TQ3RendererObject        renderer,
  244.     long                    vendorID,
  245.     long                    engineID);
  246.  
  247. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetPreferences(
  248.     TQ3RendererObject        renderer,
  249.     long                    *vendorID,
  250.     long                    *engineID);
  251.     
  252. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetDoubleBufferBypass(
  253.     TQ3RendererObject        renderer,
  254.     TQ3Boolean                bypass);
  255.  
  256. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetDoubleBufferBypass(
  257.     TQ3RendererObject        renderer,
  258.     TQ3Boolean                *bypass);
  259.  
  260. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVEContextHints(
  261.     TQ3RendererObject        renderer,
  262.     unsigned long            RAVEContextHints);
  263.  
  264. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVEContextHints(
  265.     TQ3RendererObject        renderer,
  266.     unsigned long            *RAVEContextHints);
  267.  
  268. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVETextureFilter(
  269.     TQ3RendererObject        renderer,
  270.     unsigned long            RAVEtextureFilterValue);
  271.  
  272. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVETextureFilter(
  273.     TQ3RendererObject        renderer,
  274.     unsigned long            *RAVEtextureFilterValue);
  275.  
  276.  
  277. /******************************************************************************
  278.  **                                                                             **
  279.  **                            Renderer View Tools                                 **
  280.  **                                                                             **
  281.  **                    You may only call these methods from a plug-in             **
  282.  **                                                                             **
  283.  *****************************************************************************/
  284.  
  285. /*
  286.  *    Call by a renderer to call the user "idle" method, with progress 
  287.  *    information.
  288.  *    
  289.  *    Pass in (view, 0, n) on first call
  290.  *    Pass in (view, 1..n-1, n) during rendering
  291.  *    Pass in (view, n, n) upon completion
  292.  *    
  293.  *    Note: The user must have supplied an idleProgress method with 
  294.  *    Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  295.  *    called with no progress data. e.g. the Q3View_SetIdleMethod method
  296.  *    is called instead. (current and final are ignored, essentially.)
  297.  *
  298.  *    Returns kQ3Failure if rendering is cancelled.
  299.  */
  300. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_IdleProgress(
  301.      TQ3ViewObject        view,
  302.      unsigned long        current,
  303.      unsigned long        completed);
  304.  
  305. /*
  306.  *    Called by an asynchronous renderer when it completes a frame.
  307.  */
  308. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_EndFrame(
  309.      TQ3ViewObject        view);
  310.  
  311.  
  312. /******************************************************************************
  313.  **                                                                             **
  314.  **                            Renderer AttributeSet Tools                         **
  315.  **                                                                             **
  316.  **                    You may only call these methods from a plug-in             **
  317.  **                                                                             **
  318.  *****************************************************************************/
  319.  
  320. /*
  321.  *    Faster access to geometry attribute sets.
  322.  *    
  323.  *    Returns pointer to INTERNAL data structure for elements and attributes
  324.  *    in an attributeSet, or NULL if no attribute exists.
  325.  *    
  326.  *    For attributes of type kQ3AttributeType..., the internal data structure
  327.  *    is identical to the data structure used in Q3AttributeSet_Add.
  328.  */
  329. QD3D_EXPORT void *QD3D_CALL Q3XAttributeSet_GetPointer(
  330.      TQ3AttributeSet            attributeSet,
  331.      TQ3AttributeType        attributeType);
  332.      
  333. #define kQ3XAttributeMaskNone                        \
  334.     0L
  335.  
  336. #define kQ3XAttributeMaskSurfaceUV                    \
  337.     (1 << (kQ3AttributeTypeSurfaceUV - 1))
  338.  
  339. #define kQ3XAttributeMaskShadingUV                    \
  340.     (1 << (kQ3AttributeTypeShadingUV - 1))
  341.  
  342. #define kQ3XAttributeMaskNormal                        \
  343.     (1 << (kQ3AttributeTypeNormal - 1))
  344.  
  345. #define kQ3XAttributeMaskAmbientCoefficient            \
  346.     (1 << (kQ3AttributeTypeAmbientCoefficient - 1))
  347.  
  348. #define kQ3XAttributeMaskDiffuseColor                \
  349.     (1 << (kQ3AttributeTypeDiffuseColor - 1))
  350.  
  351. #define kQ3XAttributeMaskSpecularColor                \
  352.     (1 << (kQ3AttributeTypeSpecularColor - 1))
  353.  
  354. #define kQ3XAttributeMaskSpecularControl            \
  355.     (1 << (kQ3AttributeTypeSpecularControl - 1))
  356.  
  357. #define kQ3XAttributeMaskTransparencyColor            \
  358.     (1 << (kQ3AttributeTypeTransparencyColor - 1))
  359.  
  360. #define kQ3XAttributeMaskSurfaceTangent                \
  361.     (1 << (kQ3AttributeTypeSurfaceTangent - 1))
  362.  
  363. #define kQ3XAttributeMaskHighlightState                \
  364.     (1 << (kQ3AttributeTypeHighlightState - 1))
  365.  
  366. #define kQ3XAttributeMaskSurfaceShader                \
  367.     (1 << (kQ3AttributeTypeSurfaceShader - 1))
  368.  
  369. #define kQ3XAttributeMaskCustomAttribute            0x80000000
  370.  
  371. #define kQ3XAttributeMaskAll                        \
  372.     (                                                 \
  373.         kQ3XAttributeMaskSurfaceUV             |         \
  374.         kQ3XAttributeMaskShadingUV             |         \
  375.         kQ3XAttributeMaskNormal             |         \
  376.         kQ3XAttributeMaskAmbientCoefficient |         \
  377.         kQ3XAttributeMaskDiffuseColor         |         \
  378.         kQ3XAttributeMaskSpecularColor         |         \
  379.         kQ3XAttributeMaskSpecularControl     |         \
  380.         kQ3XAttributeMaskTransparencyColor     |         \
  381.         kQ3XAttributeMaskSurfaceTangent     |         \
  382.         kQ3XAttributeMaskHighlightState        |        \
  383.         kQ3XAttributeMaskSurfaceShader        |        \
  384.         kQ3XAttributeMaskCustomAttribute            \
  385.     )
  386.  
  387. #define kQ3XAttributeMaskInherited                    \
  388.     (                                                 \
  389.         kQ3XAttributeMaskSurfaceUV             |         \
  390.         kQ3XAttributeMaskShadingUV             |         \
  391.         kQ3XAttributeMaskNormal             |         \
  392.         kQ3XAttributeMaskAmbientCoefficient |        \
  393.         kQ3XAttributeMaskDiffuseColor         |         \
  394.         kQ3XAttributeMaskSpecularColor         |         \
  395.         kQ3XAttributeMaskSpecularControl     |         \
  396.         kQ3XAttributeMaskTransparencyColor     |         \
  397.         kQ3XAttributeMaskSurfaceTangent     |         \
  398.         kQ3XAttributeMaskHighlightState              \
  399.     )
  400.  
  401. #define kQ3XAttributeMaskInterpolated                \
  402.     (                                                 \
  403.         kQ3XAttributeMaskSurfaceUV             |         \
  404.         kQ3XAttributeMaskShadingUV             |         \
  405.         kQ3XAttributeMaskNormal             |         \
  406.         kQ3XAttributeMaskAmbientCoefficient |         \
  407.         kQ3XAttributeMaskDiffuseColor         |         \
  408.         kQ3XAttributeMaskSpecularColor         |         \
  409.         kQ3XAttributeMaskSpecularControl     |         \
  410.         kQ3XAttributeMaskTransparencyColor     |         \
  411.         kQ3XAttributeMaskSurfaceTangent               \
  412.     )
  413.  
  414. typedef unsigned long TQ3XAttributeMask;
  415.  
  416. QD3D_EXPORT TQ3XAttributeMask QD3D_CALL Q3XAttributeSet_GetMask(
  417.     TQ3AttributeSet            attributeSet);
  418.  
  419.  
  420. /******************************************************************************
  421.  **                                                                             **
  422.  **                            Renderer Draw Context Tools                         **
  423.  **                                                                             **
  424.  *****************************************************************************/
  425.  
  426. typedef struct TQ3XDrawRegionPrivate    *TQ3XDrawRegion;
  427.  
  428. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetDrawRegion(
  429.     TQ3DrawContextObject    drawContext,
  430.     TQ3XDrawRegion            *drawRegion);
  431.  
  432. typedef enum TQ3XDrawContextValidationMasks {
  433.     kQ3XDrawContextValidationClearFlags            =    0x00000000L,
  434.  
  435.     kQ3XDrawContextValidationDoubleBuffer        =    1 << 0,
  436.     kQ3XDrawContextValidationShader                =    1 << 1,
  437.     kQ3XDrawContextValidationClearFunction        =    1 << 2,
  438.     kQ3XDrawContextValidationActiveBuffer        =    1 << 3,
  439.     kQ3XDrawContextValidationInternalOffScreen    =    1 << 4,
  440.     kQ3XDrawContextValidationPane                =    1 << 5,
  441.     kQ3XDrawContextValidationMask                =    1 << 6,
  442.     kQ3XDrawContextValidationDevice                =    1 << 7,
  443.     kQ3XDrawContextValidationWindow                =    1 << 8,
  444.     kQ3XDrawContextValidationWindowSize            =    1 << 9,
  445.     kQ3XDrawContextValidationWindowClip            =    1 << 10,
  446.     kQ3XDrawContextValidationWindowPosition        =    1 << 11,
  447.     kQ3XDrawContextValidationPlatformAttributes    =    1 << 12,
  448.     kQ3XDrawContextValidationForegroundShader    =    1 << 13,
  449.     kQ3XDrawContextValidationBackgroundShader    =    1 << 14,
  450.     kQ3XDrawContextValidationColorPalette        =    1 << 15,
  451.     kQ3XDrawContextValidationAll                =    ~0
  452. } TQ3XDrawContextValidationMasks;
  453.  
  454. typedef unsigned long TQ3XDrawContextValidation;
  455.  
  456. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_ClearValidationFlags(
  457.     TQ3DrawContextObject        drawContext);
  458.  
  459. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetValidationFlags(
  460.     TQ3DrawContextObject        drawContext,
  461.     TQ3XDrawContextValidation    *validationFlags);
  462.  
  463.  
  464. /******************************************************************************
  465.  **                                                                             **
  466.  **                            Renderer Draw Region Tools                         **
  467.  **                                                                             **
  468.  *****************************************************************************/
  469.  
  470. typedef enum TQ3XDevicePixelType {    /* These do not indicate byte ordering   */
  471.     kQ3XDevicePixelTypeInvalid        = 0, /* Unknown, un-initialized type     */
  472.     kQ3XDevicePixelTypeRGB32        = 1, /* Alpha:8 (ignored), R:8, G:8, B:8 */
  473.     kQ3XDevicePixelTypeARGB32        = 2, /* Alpha:8, R:8, G:8, B:8              */
  474.     kQ3XDevicePixelTypeRGB24        = 3, /* 24 bits/pixel, R:8, G:8, B:8     */
  475.     kQ3XDevicePixelTypeRGB16        = 4, /* Alpha:1 (ignored), R:5, G:5, B:5 */
  476.     kQ3XDevicePixelTypeARGB16        = 5, /* Alpha:1, R:5, G:5, B:5              */
  477.     kQ3XDevicePixelTypeRGB16_565    = 6, /* 16 bits/pixel, R:5, G:6, B:5     */
  478.     kQ3XDevicePixelTypeIndexed8        = 7, /* 8-bit color table index             */
  479.     kQ3XDevicePixelTypeIndexed4        = 8, /* 4-bit color table index             */
  480.     kQ3XDevicePixelTypeIndexed2        = 9, /* 2-bit color table index             */
  481.     kQ3XDevicePixelTypeIndexed1        = 10 /* 1-bit color table index             */
  482. } TQ3XDevicePixelType;
  483.  
  484. typedef enum TQ3XClipMaskState {
  485.     kQ3XClipMaskFullyExposed,
  486.     kQ3XClipMaskPartiallyExposed,
  487.     kQ3XClipMaskNotExposed
  488. } TQ3XClipMaskState;
  489.  
  490. typedef struct TQ3XColorDescriptor {
  491.     unsigned long            redShift;
  492.     unsigned long            redMask;
  493.     unsigned long            greenShift;
  494.     unsigned long            greenMask;
  495.     unsigned long            blueShift;
  496.     unsigned long            blueMask;
  497.     unsigned long            alphaShift;
  498.     unsigned long            alphaMask;
  499. } TQ3XColorDescriptor;
  500.  
  501. typedef struct TQ3XDrawRegionDescriptor {
  502.     unsigned long            width;
  503.     unsigned long            height;
  504.     unsigned long            rowBytes;
  505.     unsigned long            pixelSize;
  506.     TQ3XDevicePixelType        pixelType;
  507.     TQ3XColorDescriptor        colorDescriptor;
  508.     TQ3Endian                bitOrder;
  509.     TQ3Endian                byteOrder;
  510.     TQ3Bitmap                *clipMask;
  511. } TQ3XDrawRegionDescriptor;
  512.  
  513. typedef enum TQ3XDrawRegionServicesMasks {
  514.     kQ3XDrawRegionServicesNoneFlag                =    0L,
  515.     kQ3XDrawRegionServicesClearFlag                =    1 << 0,
  516.     kQ3XDrawRegionServicesDontLockDDSurfaceFlag    =    1 << 1
  517. } TQ3XDrawRegionServicesMasks;
  518.  
  519. typedef unsigned long TQ3XDrawRegionServices;
  520.  
  521. typedef void (QD3D_CALLBACK *TQ3XDrawRegionRendererPrivateDeleteMethod)(
  522.     void    *rendererPrivate);
  523.  
  524. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleX( 
  525.     TQ3XDrawRegion     drawRegion,
  526.     float            *deviceScaleX);
  527.  
  528. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleY( 
  529.     TQ3XDrawRegion     drawRegion,
  530.     float            *deviceScaleY);
  531.  
  532.  
  533. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetX( 
  534.     TQ3XDrawRegion     drawRegion,
  535.     float            *deviceOffsetX);
  536.  
  537. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetY( 
  538.     TQ3XDrawRegion     drawRegion,
  539.     float            *deviceOffsetX);
  540.  
  541.  
  542. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleX( 
  543.     TQ3XDrawRegion     drawRegion,
  544.     float            *windowScaleX);
  545.  
  546. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleY( 
  547.     TQ3XDrawRegion     drawRegion,
  548.     float            *windowScaleY);
  549.  
  550.  
  551. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetX( 
  552.     TQ3XDrawRegion     drawRegion,
  553.     float            *windowOffsetX);
  554.  
  555. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetY( 
  556.     TQ3XDrawRegion     drawRegion,
  557.     float            *windowOffsetY);
  558.  
  559. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_IsActive( 
  560.     TQ3XDrawRegion     drawRegion,
  561.     TQ3Boolean        *isActive);
  562.  
  563.  
  564. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetNextRegion( 
  565.     TQ3XDrawRegion     drawRegion,
  566.     TQ3XDrawRegion    *nextDrawRegion);
  567.  
  568. /* 
  569.  *  One of the next two functions must be called before using a draw region 
  570.  */
  571.  
  572. /*
  573.  *    Use this Start function if double buffering/image access services from the
  574.  *    Draw Context are not needed, you may still request clear for example
  575.  */
  576. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_Start( 
  577.     TQ3XDrawRegion                drawRegion, 
  578.     TQ3XDrawRegionServices        services,
  579.     TQ3XDrawRegionDescriptor    **descriptor);
  580.  
  581. /*
  582.  *    Use this Start function if double buffering or image access services from 
  583.  *  the Draw Context are needed.
  584.  */
  585. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_StartAccessToImageBuffer( 
  586.     TQ3XDrawRegion                drawRegion, 
  587.     TQ3XDrawRegionServices        services,
  588.     TQ3XDrawRegionDescriptor    **descriptor,
  589.     void                        **image);
  590.  
  591. /*
  592.  *    This function is used to indicate that access to a DrawRegion is ended.
  593.  */
  594. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_End( 
  595.     TQ3XDrawRegion         drawRegion);
  596.  
  597. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceTransform( 
  598.     TQ3XDrawRegion         drawRegion,
  599.     TQ3Matrix4x4        **deviceTransform);
  600.  
  601. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipFlags( 
  602.     TQ3XDrawRegion         drawRegion,
  603.     TQ3XClipMaskState    *clipMaskState);
  604.     
  605. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipMask( 
  606.     TQ3XDrawRegion         drawRegion,
  607.     TQ3Bitmap            **clipMask);
  608.     
  609. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  610.  
  611. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipRegion(
  612.     TQ3XDrawRegion    drawRegion,
  613.     RgnHandle        *rgnHandle);
  614.     
  615. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetGDHandle(
  616.     TQ3XDrawRegion    drawRegion,
  617.     GDHandle        *gdHandle);
  618.     
  619. #endif  /* WINDOW_SYSTEM_MACINTOSH  */     
  620.  
  621. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetRendererPrivate( 
  622.     TQ3XDrawRegion     drawRegion,
  623.     void            **rendererPrivate);
  624.  
  625. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetRendererPrivate( 
  626.     TQ3XDrawRegion                                 drawRegion, 
  627.     const void                                     *rendererPrivate,
  628.     TQ3XDrawRegionRendererPrivateDeleteMethod    deleteMethod);
  629.  
  630. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetUseDefaultRendererFlag( 
  631.     TQ3XDrawRegion    drawRegion, 
  632.     TQ3Boolean         flag);
  633.  
  634. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetUseDefaultRendererFlag( 
  635.     TQ3XDrawRegion    drawRegion,
  636.     TQ3Boolean        *useDefaultRenderingFlag);
  637.  
  638.  
  639.  
  640. /******************************************************************************
  641.  **                                                                             **
  642.  **                            Renderer Class Methods                             **
  643.  **                                                                             **
  644.  *****************************************************************************/
  645. /*
  646.  *    Methods from Object
  647.  *        kQ3XMethodTypeObjectClassRegister
  648.  *        kQ3XMethodTypeObjectClassUnregister
  649.  *        kQ3XMethodTypeObjectNew
  650.  *        kQ3XMethodTypeObjectDelete
  651.  *        kQ3XMethodTypeObjectRead
  652.  *        kQ3XMethodTypeObjectTraverse
  653.  *        kQ3XMethodTypeObjectWrite
  654.  *        
  655.  *    Methods from Shared
  656.  *        kQ3MethodTypeSharedEdited
  657.  *
  658.  *    Renderer Methods
  659.  *    
  660.  *    The renderer methods should be implemented according to the type
  661.  *    of renderer being written.
  662.  *
  663.  *    For the purposes of documentation, there are two basic types of
  664.  *    renderers: 
  665.  *
  666.  *        Interactive
  667.  *            Interactive Renderer
  668.  *            WireFrame Renderer
  669.  *        
  670.  *        Deferred
  671.  *            a ray-tracer
  672.  *            painter's algorithm renderer (cached in a BSP triangle tree)
  673.  *            an artistic renderer (simulates a pencil drawing, etc.)
  674.  *
  675.  *    The main difference is how each renderer handles incoming state and 
  676.  *    geometry.
  677.  *
  678.  *    An interactive renderer immediately transforms, culls, and shades
  679.  *    incoming geometry and performs rasterization. For example, in a 
  680.  *    single-buffered WireFrame renderer, you will see a new triangle
  681.  *    immediately after Q3Triangle_Draw (if it's visible, of course).
  682.  *
  683.  *    A deferred renderer caches the view state and each geometry, 
  684.  *    converting into any internal queue of drawing commands. Rasterization
  685.  *    is not actually performed until all data has been submitted.
  686.  *    
  687.  *    For example, a ray-tracer may not rasterize anything until the
  688.  *    end of the rendering loop, or until an EndFrame call is made.
  689.  */
  690.  
  691.     
  692. /******************************************************************************
  693.  **                                                                             **
  694.  **                        Renderer User Interface Methods                         **
  695.  **                                                                             **
  696.  *****************************************************************************/
  697.  
  698. /*
  699.  *    kQ3XMethodTypeRendererIsInteractive
  700.  *    
  701.  *    There is no actual method with this - the metahandler simply returns
  702.  *  "(TQ3XFunctionPointer)kQ3True" for this "method" if the renderer is 
  703.  *  intended to be used in interactive settings, and   
  704.  *    "(TQ3XFunctionPointer)kQ3False" otherwise. 
  705.  *  
  706.  *  If neither value is specified in the metahandler, the renderer 
  707.  *  is *assumed to be non-interactive*!!!
  708.  *    
  709.  *    OPTIONAL
  710.  */
  711. #define kQ3XMethodTypeRendererIsInteractive    Q3_METHOD_TYPE('i','s','i','n')    
  712.  
  713.  
  714. /*
  715.  *    TQ3XRendererModalConfigureMethod
  716.  *    
  717.  *    This method should pop up a modal dialog to edit the renderer settings 
  718.  *    found in the renderer private. 
  719.  *    
  720.  *    dialogAnchor - is platform specific data passed by the client to support
  721.  *      movable modal dialogs. 
  722.  *    MacOS: this is a callback to the calling application's event handler.
  723.  *      The renderer calls this function with events not handled by the 
  724.  *      settings dialog. This is necessary in order to support movable modal 
  725.  *      dialogs. An application's event handler must return kQ3True if it 
  726.  *      handles the event passed to the callback or kQ3False if not. 
  727.  *      An application which doesn't want to support a movable modal configure
  728.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  729.  *      A renderer should implement a non-movable style dialog in that case.
  730.  *    Win32: this is the HWND of the owning window (typically an application's
  731.  *      main window).  (Win32 application modal dialogs are always movable.)
  732.  *  canceled - returns a boolean inditacating that the user canceled the 
  733.  *    dialog.
  734.  *    
  735.  *    OPTIONAL
  736.  */
  737. #define kQ3XMethodTypeRendererModalConfigure \
  738.     Q3_METHOD_TYPE('r','d','m','c')    
  739. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererModalConfigureMethod)(
  740.     TQ3RendererObject            renderer,
  741.     TQ3DialogAnchor             dialogAnchor, 
  742.     TQ3Boolean                    *canceled,    
  743.     void                        *rendererPrivate);
  744.  
  745. /*
  746.  *    kQ3XMethodTypeRendererGetNickNameString
  747.  *    
  748.  *        Allows an application to collect the name of the renderer for
  749.  *        display in a user interface item such as a menu.
  750.  *    
  751.  *        If dataBuffer is NULL actualDataSize returns the required size in 
  752.  *        bytes of a data buffer large enough to store the renderer name. 
  753.  *
  754.  *      bufferSize is the actual size of the memory block pointed to by 
  755.  *        dataBuffer
  756.  *
  757.  *        actualDataSize - on return the actual number of bytes written to the
  758.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  759.  *
  760.  *    OPTIONAL
  761.  */
  762. #define kQ3XMethodTypeRendererGetNickNameString \
  763.     Q3_METHOD_TYPE('r','d','n','s')    
  764. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererGetNickNameStringMethod)(
  765.     unsigned char                *dataBuffer, 
  766.     unsigned long                bufferSize,
  767.     unsigned long                *actualDataSize);
  768.     
  769. /*
  770.  *    kQ3XMethodTypeRendererGetConfigurationData
  771.  *    
  772.  *        Allows an application to collect private configuration data from the
  773.  *      renderer which it will then save. For example in a preference file, 
  774.  *      a registry key (on Windows) or in a style template. An application 
  775.  *      should tag this data with the renderer's object name.
  776.  *    
  777.  *        If dataBuffer is NULL actualDataSize returns the required size in 
  778.  *        bytes of a data buffer large enough to store private data. 
  779.  *
  780.  *      bufferSize is the actual size of the memory block pointed to by 
  781.  *        dataBuffer
  782.  *
  783.  *        actualDataSize - on return the actual number of bytes written to the
  784.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  785.  *
  786.  *    OPTIONAL
  787.  */
  788. #define kQ3XMethodTypeRendererGetConfigurationData \
  789.     Q3_METHOD_TYPE('r','d','g','p')    
  790. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererGetConfigurationDataMethod)(
  791.     TQ3RendererObject            renderer, 
  792.     unsigned char                *dataBuffer, 
  793.     unsigned long                bufferSize,
  794.     unsigned long                *actualDataSize,    
  795.     void                        *rendererPrivate);
  796.  
  797. /*
  798.  *    TQ3XRendererSetConfigurationDataMethod
  799.  *    
  800.  *        Allows an application to pass private configuration data which has
  801.  *         previously  been obtained from a renderer via 
  802.  *        Q3Renderer_GetConfigurationData. For example in a preference file or 
  803.  *        in a style template. An application should tag this data with the 
  804.  *        renderer's object name.
  805.  *    
  806.  *      bufferSize is the actual size of the memory block pointed to by 
  807.  *        dataBuffer
  808.  *
  809.  *    OPTIONAL
  810.  */
  811. #define kQ3XMethodTypeRendererSetConfigurationData \
  812.     Q3_METHOD_TYPE('r','d','s','p')    
  813. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSetConfigurationDataMethod)(
  814.     TQ3RendererObject            renderer, 
  815.     unsigned char                *dataBuffer, 
  816.     unsigned long                bufferSize,    
  817.     void                        *rendererPrivate);
  818.  
  819.  
  820. /******************************************************************************
  821.  **                                                                             **
  822.  **                        Renderer Drawing State Methods                         **
  823.  **                                                                             **
  824.  *****************************************************************************/
  825. /*
  826.  *    TQ3RendererStartFrame
  827.  *    
  828.  *    The StartFrame method is called first at Q3View_StartRendering
  829.  *    and should:
  830.  *        - initialize any renderer state to defaults
  831.  *        - extract any and all useful data from the drawContext
  832.  *
  833.  *    If your renderer passed in kQ3RendererFlagClearBuffer at 
  834.  *    registration, then it should also:
  835.  *        - clear the drawContext 
  836.  *    
  837.  *        When clearing, your renderer may opt to:
  838.  *        - NOT clear anything (if you touch every pixel, for example)
  839.  *        - to clear with your own routine, or
  840.  *        - to use the draw context default clear method by calling 
  841.  *        Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  842.  *        any available hardware in the system for clearing.
  843.  *    
  844.  *    This call also signals the start of all default submit commands from
  845.  *    the view. The renderer will receive updates for the default view
  846.  *    state via its Update methods before StartPass is called.
  847.  *    
  848.  *    REQUIRED
  849.  */
  850. #define kQ3XMethodTypeRendererStartFrame    \
  851.     Q3_METHOD_TYPE('r','d','c','l')
  852. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartFrameMethod)(
  853.     TQ3ViewObject            view,
  854.     void                    *rendererPrivate,
  855.     TQ3DrawContextObject    drawContext);
  856.     
  857. /*
  858.  *    kQ3XMethodTypeRendererStartPass
  859.  *    TQ3XRendererStartPassMethod
  860.  *    
  861.  *    The StartPass method is called during Q3View_StartRendering but after
  862.  *    the StartFrame command. It should:
  863.  *        - collect camera and light information
  864.  *    
  865.  *    If your renderer supports deferred camera transformation, camera is the
  866.  *    main camera which will be submitted in the hierarchy somewhere. It
  867.  *    is never NULL.
  868.  *
  869.  *    If your renderer does not support deferred camera transformation, camera
  870.  *    is the transformed camera.
  871.  *
  872.  *    If your renderer supports deferred light transformation, lights will be
  873.  *    NULL, and will be submitted to your light draw methods instead.
  874.  *
  875.  *    This call signals the end of the default update state, and the start of 
  876.  *  submit commands from the user to the view.
  877.  *
  878.  *    REQUIRED
  879.  */
  880. #define kQ3XMethodTypeRendererStartPass \
  881.     Q3_METHOD_TYPE('r','d','s','t')
  882. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartPassMethod)(
  883.     TQ3ViewObject            view,
  884.     void                    *rendererPrivate,
  885.     TQ3CameraObject            camera,
  886.     TQ3GroupObject            lightGroup);
  887.  
  888. /*
  889.  *    kQ3XMethodTypeRendererFlushFrame
  890.  *    TQ3XRendererFlushFrameMethod
  891.  *    
  892.  *    This call is only implemented by asynchronous renderers.
  893.  *    
  894.  *    The FlushFrame method is called between the StartPass and EndPass
  895.  *    methods and is called when the user wishes to flush any asynchronous
  896.  *    drawing tasks (which draw to the drawcontext), but does not want 
  897.  *    to block.
  898.  *    
  899.  *    The result of this call is that an image should "eventually" appear
  900.  *    asynchronously.
  901.  *    
  902.  *    For asynchronous rendering, this call is non-blocking.
  903.  *    
  904.  *    An interactive renderer should ensure that all received
  905.  *    geometries are drawn in the image.
  906.  *    
  907.  *    An interactive renderer that talks to hardware should force
  908.  *    the hardware to generate an image.
  909.  *    
  910.  *    A deferred renderer should exhibit a similar behaviour,
  911.  *    though it is not required.  A deferred renderer should spawn
  912.  *    a process that generates a partial image from the currently
  913.  *    accumulated drawing state. 
  914.  *    
  915.  *    However, for renderers such as ray-tracers which generally are
  916.  *    quite compute-intensive, FlushFrame is not required and is a no-op.
  917.  *
  918.  *    OPTIONAL
  919.  */
  920. #define kQ3XMethodTypeRendererFlushFrame    \
  921.     Q3_METHOD_TYPE('r','d','f','l')
  922. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererFlushFrameMethod)(
  923.     TQ3ViewObject            view,
  924.     void                    *rendererPrivate,
  925.     TQ3DrawContextObject    drawContext);
  926.  
  927. /*
  928.  *    kQ3XMethodTypeRendererEndPass
  929.  *    TQ3XRendererEndPassMethod
  930.  *    
  931.  *    The EndPass method is called at Q3View_EndRendering and signals
  932.  *    the end of submit commands to the view.
  933.  *
  934.  *    If an error occurs, the renderer should call Q3XError_Post and
  935.  *    return kQ3ViewStatusError.
  936.  *    
  937.  *    If a renderer requires another pass on the renderering data,
  938.  *    it should return kQ3ViewStatusRetraverse.
  939.  *    
  940.  *    If rendering was cancelled, this function will not be called
  941.  *    and the view will handle returning kQ3ViewStatusCancelled;
  942.  *    
  943.  *    Otherwise, your renderer should begin completing the process of 
  944.  *    generating the image in the drawcontext. If you have buffered
  945.  *    any drawing data, flush it. RendererEnd should have a similar
  946.  *    effect as RendererFlushFrame.
  947.  *    
  948.  *    If the renderer is synchronous:
  949.  *        - complete rendering of the entire frame
  950.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer
  951.  *            - Update the front buffer
  952.  *        else
  953.  *            - DrawContext will update the front buffer after returning
  954.  *
  955.  *    If the renderer is asynchronous
  956.  *        - spawn rendering thread for entire frame
  957.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  958.  *            - you must eventually update the front buffer asynchronously
  959.  *        else
  960.  *            - you must eventually update the back buffer asynchronously
  961.  *            
  962.  *    REQUIRED
  963.  */
  964. #define kQ3XMethodTypeRendererEndPass    \
  965.     Q3_METHOD_TYPE('r','d','e','d')
  966. typedef TQ3ViewStatus (QD3D_CALLBACK *TQ3XRendererEndPassMethod)(
  967.     TQ3ViewObject            view,
  968.     void                    *rendererPrivate);
  969.  
  970. /*
  971.  *    kQ3XMethodTypeRendererEndFrame
  972.  *    TQ3XRendererEndFrame
  973.  *    
  974.  *    This call is only implemented by asynchronous renderers.
  975.  *
  976.  *    The EndFrame method is called from Q3View_Sync, which is
  977.  *    called after Q3View_EndRendering and signals that the user
  978.  *    wishes to see the completed image and is willing to block.
  979.  *    
  980.  *    If your renderer supports kQ3RendererFlagDoubleBuffer
  981.  *        - update the front buffer completely 
  982.  *    else
  983.  *        - update the back buffer completely
  984.  *
  985.  *    This call is equivalent in functionality to RendererFlushFrame
  986.  *    but blocks until the image is completed.
  987.  *    
  988.  *    If no method is supplied, the default is a no-op.
  989.  *    
  990.  *    NOTE: Registering a method of this type indicates that your renderer will
  991.  *    be rendering after Q3View_EndRendering has been called.
  992.  *    
  993.  *    OPTIONAL
  994.  */
  995. #define kQ3XMethodTypeRendererEndFrame    \
  996.     Q3_METHOD_TYPE('r','d','s','y')
  997. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererEndFrameMethod)(
  998.     TQ3ViewObject            view,
  999.     void                    *rendererPrivate,
  1000.     TQ3DrawContextObject    drawContext);
  1001.     
  1002. /*
  1003.  *    The RendererCancel method is called after Q3View_StartRendering
  1004.  *    and signals the termination of all rendering operations.
  1005.  *
  1006.  *    A renderer should clean up any cached data, and cancel all 
  1007.  *    rendering operations.
  1008.  *    
  1009.  *    If called before Q3View_EndRendering, the RendererEnd method
  1010.  *    is NOT called.
  1011.  *    
  1012.  *    If called after Q3View_EndRendering, the renderer should kill
  1013.  *    any threads and terminate any further rendering.
  1014.  *    
  1015.  *    REQUIRED
  1016.  */
  1017. #define kQ3XMethodTypeRendererCancel    \
  1018.     Q3_METHOD_TYPE('r','d','a','b')
  1019. typedef void (QD3D_CALLBACK *TQ3XRendererCancelMethod)(
  1020.     TQ3ViewObject            view,
  1021.     void                    *rendererPrivate);
  1022.  
  1023.  
  1024. /******************************************************************************
  1025.  **                                                                             **
  1026.  **                        Renderer DrawContext Methods                         **
  1027.  **                                                                             **
  1028.  *****************************************************************************/
  1029.  
  1030. /*
  1031.  *    kQ3XMethodTypeRendererPush
  1032.  *    TQ3XRendererPushMethod
  1033.  *    
  1034.  *    kQ3XMethodTypeRendererPop
  1035.  *    TQ3XRendererPopMethod
  1036.  *    
  1037.  *    These methods are called whenever the graphics state in the view
  1038.  *    is pushed or popped. The user may isolate state by calling:
  1039.  *    
  1040.  *    Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1041.  *    Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1042.  *    Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1043.  *    Q3Box_Submit(&unitBox, view);
  1044.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1045.  *    Q3Push_Submit(view);
  1046.  *        Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1047.  *        Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1048.  *        Q3Box_Submit(&unitBox, view);
  1049.  *    Q3Pop_Submit(view);    
  1050.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1051.  *    Q3Box_Submit(&unitBox, view);
  1052.  *    
  1053.  *    or by submitting a display group which pushes and pops.
  1054.  *    
  1055.  *    If you support RendererPush and RendererPop in your renderer:
  1056.  *        - you must maintain your drawing state as a stack, as well.
  1057.  *        - you will not be updated with the popped state after
  1058.  *            RendererPop is called.
  1059.  *
  1060.  *    If you do not support Push and Pop in your renderer:
  1061.  *        - you may maintain a single copy of the drawing state.
  1062.  *        - you will be updated with changed fields after the view stack is
  1063.  *            popped.
  1064.  *
  1065.  *    A renderer that supports Push and Pop gets called in the following
  1066.  *    sequence (from example above):
  1067.  *    
  1068.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1069.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1070.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1071.  *    RendererUpdateMatrixLocalToWorld(...)
  1072.  *    RendererSubmitGeometryBox(...)
  1073.  *    RendererPush(...)
  1074.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1075.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1076.  *        RendererSubmitGeometryBox(...)
  1077.  *    RendererPop(...)
  1078.  *    RendererUpdateMatrixLocalToWorld(...)
  1079.  *    RendererSubmitGeometryBox(...)
  1080.  *
  1081.  *    A renderer that does not supports Push and Pop gets called in the
  1082.  *    following sequence:
  1083.  *    
  1084.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1085.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1086.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1087.  *    RendererUpdateMatrixLocalToWorld(...)
  1088.  *    RendererSubmitGeometryBox(...)
  1089.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1090.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1091.  *        RendererSubmitGeometryBox(...)
  1092.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1093.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1094.  *    RendererUpdateMatrixLocalToWorld(...)
  1095.  *    RendererSubmitGeometryBox(...)
  1096.  *    
  1097.  */
  1098. #define kQ3XMethodTypeRendererPush    \
  1099.     Q3_METHOD_TYPE('r','d','p','s')
  1100. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPushMethod)(
  1101.     TQ3ViewObject            view,
  1102.     void                    *rendererPrivate);
  1103.  
  1104. #define kQ3XMethodTypeRendererPop    \
  1105.     Q3_METHOD_TYPE('r','d','p','o')
  1106. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPopMethod)(
  1107.     TQ3ViewObject            view,
  1108.     void                    *rendererPrivate);
  1109.  
  1110.  
  1111. /******************************************************************************
  1112.  **                                                                             **
  1113.  **                            Renderer Cull Methods                             **
  1114.  **                                                                             **
  1115.  *****************************************************************************/
  1116. /*
  1117.  *    kQ3XMethodTypeRendererIsBoundingBoxVisible
  1118.  *    TQ3XRendererIsBoundingBoxVisibleMethod
  1119.  *    
  1120.  *    This method is called to cull complex groups and geometries 
  1121.  *    given their bounding box in local space.
  1122.  *    
  1123.  *    It should transform the local-space bounding box coordinates to
  1124.  *    frustum space and return a TQ3Boolean return value indicating
  1125.  *    whether the box appears within the viewing frustum.
  1126.  *    
  1127.  *    If no method is supplied, the default behavior is to return
  1128.  *    kQ3True.
  1129.  *    
  1130.  */
  1131. #define kQ3XMethodTypeRendererIsBoundingBoxVisible    \
  1132.     Q3_METHOD_TYPE('r','d','b','x')
  1133. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XRendererIsBoundingBoxVisibleMethod)(
  1134.     TQ3ViewObject            view,
  1135.     void                    *rendererPrivate,
  1136.     const TQ3BoundingBox    *bBox);
  1137.  
  1138.  
  1139.  
  1140. /******************************************************************************
  1141.  **                                                                             **
  1142.  **                        Renderer Object Support Methods                         **
  1143.  **                                                                             **
  1144.  *****************************************************************************/
  1145.  
  1146. /*
  1147.  *    Drawing methods (Geometry, Camera, Lights)
  1148.  *
  1149.  */
  1150.  
  1151. /*
  1152.  *    Geometry MetaHandler
  1153.  *    
  1154.  *    This metaHandler is required to support 
  1155.  *    
  1156.  *    kQ3GeometryTypeTriangle
  1157.  *    kQ3GeometryTypeLine
  1158.  *    kQ3GeometryTypePoint
  1159.  *    kQ3GeometryTypeMarker
  1160.  *    kQ3GeometryTypePixmapMarker
  1161.  *    
  1162.  *    REQUIRED
  1163.  */
  1164. #define kQ3XMethodTypeRendererSubmitGeometryMetaHandler    \
  1165.     Q3_METHOD_TYPE('r','d','g','m')
  1166. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMetaHandlerMethod)(
  1167.     TQ3ObjectType                    geometryType);
  1168. /*
  1169.  *    The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1170.  *    of kQ3GeometryTypeFoo and returns methods of type:
  1171.  */
  1172. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMethod)(
  1173.     TQ3ViewObject                    view,
  1174.     void                            *rendererPrivate,
  1175.     TQ3GeometryObject                geometry,
  1176.     const void                        *publicData);
  1177.  
  1178.  
  1179. /*
  1180.  *    Camera MetaHandler
  1181.  *    
  1182.  *    This metaHandler, if supplied, indicates that your renderer
  1183.  *    handles deferred transformation of the main camera within a scene.
  1184.  *    
  1185.  *    If not supplied, or an unsupported camera is used, the view will do
  1186.  *    the transformation for the renderer and pass in a camera in the 
  1187.  *    StartPass method.
  1188.  *    
  1189.  *    OPTIONAL
  1190.  */
  1191. #define kQ3XMethodTypeRendererSubmitCameraMetaHandler    \
  1192.     Q3_METHOD_TYPE('r','d','c','m')
  1193. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitCameraMetaHandlerMethod)(
  1194.     TQ3ObjectType                    cameraType);
  1195. /*
  1196.  *    The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1197.  *    of kQ3CameraTypeFoo and returns methods of type:
  1198.  */
  1199. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitCameraMethod)(
  1200.     TQ3ViewObject                    view,
  1201.     void                            *rendererPrivate,
  1202.     TQ3CameraObject                    camera,
  1203.     const void                        *publicData);
  1204.  
  1205.  
  1206. /*
  1207.  *    Light MetaHandler
  1208.  *    
  1209.  *    This metaHandler, if supplied, indicates that your renderer
  1210.  *    handles deferred transformation of lights within a scene.
  1211.  *    
  1212.  *    If an unsupported light is encountered, it is ignored.
  1213.  *
  1214.  *    OPTIONAL
  1215.  */
  1216. #define kQ3XMethodTypeRendererSubmitLightMetaHandler    \
  1217.     Q3_METHOD_TYPE('r','d','l','g')
  1218. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitLightMetaHandlerMethod)(
  1219.     TQ3ObjectType                    lightType);
  1220. /*
  1221.  *    The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1222.  *    of kQ3LightTypeFoo and returns methods of type:
  1223.  */
  1224. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitLightMethod)(
  1225.     TQ3ViewObject                    view,
  1226.     void                            *rendererPrivate,
  1227.     TQ3LightObject                    light,
  1228.     const void                        *publicData);
  1229.  
  1230. /*
  1231.  *
  1232.  *    Update methods
  1233.  *
  1234.  *    They are called whenever the state has changed. If the renderer supports
  1235.  *    the RendererPush and RendererPop methods, it must maintain its own state
  1236.  *    stack. Updates are not called for changed data when the view stack is
  1237.  *    popped.
  1238.  *
  1239.  *    See the comments for the RendererPush and RendererPop methods above
  1240.  *    for an example of how data is updated.
  1241.  *
  1242.  */
  1243.  
  1244. /*
  1245.  *    Style
  1246.  */
  1247. #define kQ3XMethodTypeRendererUpdateStyleMetaHandler        \
  1248.     Q3_METHOD_TYPE('r','d','y','u')
  1249. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateStyleMetaHandlerMethod)(
  1250.     TQ3ObjectType                    styleType);
  1251. /*
  1252.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1253.  *    of kQ3StyleTypeFoo and returns methods of type:
  1254.  */
  1255. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateStyleMethod)(
  1256.     TQ3ViewObject                    view,
  1257.     void                            *rendererPrivate,
  1258.     const void                        *publicData);
  1259.  
  1260. /*
  1261.  *    Attributes
  1262.  */
  1263. #define kQ3XMethodTypeRendererUpdateAttributeMetaHandler    \
  1264.     Q3_METHOD_TYPE('r','d','a','u')
  1265. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMetaHandlerMethod)(
  1266.     TQ3AttributeType                attributeType);
  1267. /*
  1268.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1269.  *    of kQ3AttributeTypeFoo and returns methods of type:
  1270.  */
  1271. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMethod)(
  1272.     TQ3ViewObject                    view,
  1273.     void                            *rendererPrivate,
  1274.     const void                        *publicData);
  1275.  
  1276. /*
  1277.  *    Shaders
  1278.  */
  1279. #define kQ3XMethodTypeRendererUpdateShaderMetaHandler    \
  1280.     Q3_METHOD_TYPE('r','d','s','u')
  1281. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateShaderMetaHandlerMethod)(
  1282.     TQ3ObjectType                    shaderType);
  1283.     
  1284. /*
  1285.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1286.  *    of kQ3ShaderTypeFoo and returns methods of type:
  1287.  */
  1288. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateShaderMethod)(
  1289.     TQ3ViewObject                    view,
  1290.     void                            *rendererPrivate,
  1291.     TQ3Object                        *shaderObject);
  1292.  
  1293. /*
  1294.  *    Matrices
  1295.  */
  1296. #define kQ3XMethodTypeRendererUpdateMatrixMetaHandler                    \
  1297.     Q3_METHOD_TYPE('r','d','x','u')
  1298. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1299.  
  1300. /*
  1301.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1302.  *    of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1303.  */
  1304. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorld                    \
  1305.     Q3_METHOD_TYPE('u','l','w','x')
  1306. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse            \
  1307.     Q3_METHOD_TYPE('u','l','w','i')
  1308. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose    \
  1309.     Q3_METHOD_TYPE('u','l','w','t')
  1310. #define kQ3XMethodTypeRendererUpdateMatrixLocalToCamera                    \
  1311.     Q3_METHOD_TYPE('u','l','c','x')
  1312. #define kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum                \
  1313.     Q3_METHOD_TYPE('u','l','f','x')
  1314. #define kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum                \
  1315.     Q3_METHOD_TYPE('u','w','f','x')
  1316.  
  1317. /*
  1318.  *    and returns methods of type:
  1319.  */
  1320. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateMatrixMethod)(
  1321.     TQ3ViewObject                    view,
  1322.     void                            *rendererPrivate,
  1323.     const TQ3Matrix4x4                *matrix);
  1324.  
  1325. #ifdef __cplusplus
  1326. }
  1327. #endif    /* __cplusplus */
  1328.  
  1329. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  1330.  
  1331. #if defined(__xlc__) || defined(__XLC121__)
  1332.     #pragma options enum=reset
  1333.     #pragma options align=reset
  1334. #elif defined(__MWERKS__)
  1335.     #pragma enumsalwaysint reset
  1336.     #pragma options align=reset
  1337. #elif defined(__MRC__) || defined(__SC__)
  1338.     #if PRAGMA_ENUM_RESET_QD3DRENDER
  1339.         #pragma options(pack_enums)
  1340.         #undef PRAGMA_ENUM_RESET_QD3DRENDER
  1341.     #endif
  1342.     #pragma options align=reset
  1343. #endif
  1344.  
  1345. #endif  /* OS_MACINTOSH */
  1346.  
  1347. #endif  /*  QD3DRenderer_h  */
  1348.